package com.agileai.bpm.service.running;

import java.util.List;

import com.agileai.bpm.domain.define.Process;
import com.agileai.bpm.domain.running.ActivityInstance;
import com.agileai.bpm.domain.running.ProcessInstance;
import com.agileai.bpm.domain.running.WorkAttributes;
import com.agileai.bpm.domain.running.WorkItem;
import com.agileai.domain.DataRow;

public interface ProcessEngine {
	public void initialize();
	public void registryProcess(String processId, Process process);
	
	public DataRow getProcessId8InstIdRow(String processCode,String bizRecordId);
	public Process retrieveProcess(String processId) throws RunningException;
	public ProcessInstance retrieveProcessInstance(String processInstanceId) throws RunningException;
	public void createInstance(ProcessInstance processInstance,WorkAttributes workAttributes,boolean skipFirstNode) throws RunningException;
	public void transitInstance(ActivityInstance activityInstance,WorkAttributes workAttributes) throws RunningException;
	public void terminateInstance(String processInstatnceId) throws RunningException;
	public void saveDraft(String processId,String userId,String bizRecordId,String bizTitle,String bizCode) throws RunningException;
	
	public void deleteInstanceAndHistorys(String processURI,String bizRecordId) throws RunningException;
	public void updateInstance(ProcessInstance processInstance) throws RunningException;

	public List<WorkItem> findWorkItemList(String seq,String type);
	
	public boolean isOwnTaskItem(String userId, String processInstanceId, String activityCode);
	
	public DataRow findUserRow(String seq,String type);
	
	public DataRow findWorkItemRow(String processInstId,String userCode,String activityCode);
	
	public void updateWorkItem(String processInstId,String activityInstId,String userId,String delegateeId);
	
	public String findCurrentProcessId(String processCode);
	
	public void insertProcessLog(ProcessInstance processInstance,String actionType,String actionUser,String actionInstId,String descrption);
}
